/**
 * Asynchronous request to retreive an HTML fragment
 * @param url the URL from which the HTML fragment must be retreived
 * @param target the target DOM id which "innerHTML" is to be updated
 */
function ahah(url, target, waitImagePath) {
  document.getElementById(target).innerHTML = "<center>Fetching data ...<br/><img src=\""+waitImagePath+"/ajax-loader.gif\"/></center>";
  if (window.XMLHttpRequest) {
    req = new XMLHttpRequest();
  } else if (window.ActiveXObject) {
    req = new ActiveXObject("Microsoft.XMLHTTP");
  }
  if (req != undefined) {
    req.onreadystatechange = function() {ahahDone(url, target);};
    req.open("GET", url, true);
    req.send("");
  }
}  
	
/**
 * Function which is called when the HTML fragment has been loaded by ahah()
 * @param url the URL from which the HTML fragment must be retreived
 * @param target the target DOM id which "innerHTML" is to be updated
 */
function ahahDone(url, target) {
  if (req.readyState == 4) { // only if req is "loaded"
    if (req.status == 200) { // only if "OK"
      document.getElementById(target).innerHTML = req.responseText;
    } else {
      document.getElementById(target).innerHTML="Error:\n"+ req.status + "\n" +req.statusText;
    }
  }
}